package com.leen.admin.controller;


import com.leen.admin.dto.JobDTO;
import com.leen.admin.entity.Job;
import com.leen.admin.repository.JobRepository;
import com.leen.admin.service.Jobservice;
import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "岗位api")
@RequestMapping(value = "/admin")
public class JobController {
    //增删改使用@PostMapping(value = "/job/add")  查找使用getmapping



    @Autowired
    private Jobservice jobservice;

    @Autowired
    private JobRepository jobRepository;



    @ApiOperation(value = "查询数据")
    @GetMapping(value = "/job/data")
    public ResultVO<ResultVO> search(JobDTO jobDTO){
        return ResultVO.success(this.jobservice.search(jobDTO));
    }

   @ApiOperation(value = "新增数据")
    @PostMapping(value = "/job/add")
    public ResultVO<String>add(@RequestBody Job job){
        Job save=this.jobservice.save(job);
        return save!=null?ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
   }


   @ApiOperation(value = "修改数据")
    @PostMapping(value = "/job/update")
    public ResultVO<String>update(@RequestBody Job job){
        Job update=this.jobservice.save(job);
        return update!=null?ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
   }


   @ApiOperation(value = "分页查询")
    @GetMapping(value = "/job/searchPage")
    public ResultVO<String>searchPage(JobDTO jobDTO){
       ResponseVO search=this.jobservice.search(jobDTO);
       return ResultVO.success(search);
   }

}




















